<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
      .app {
        width: 100vw;
      }
      h3 {
        text-align: center;
      }
      table {
        width: 600px;
        text-align: center;
        margin: 0 auto;
        border: 1px solid #000;
      }
      th,
      td {
        border: 1px solid #000;
      }
    </style>
  </head>
  <body>
    <div class="app">
      <h3>欢迎光临_vue开发的收银系统_水果店</h3>
      <table style="border: 1">
        <tr>
          <th>苹果10￥/斤，折扣< 8折 ></th>
        </tr>
        <tr>
          <td>
            <span>请输入你要购买的斤数</span>
            <input type="number" v-model="count" />
          </td>
        </tr>
        <tr>
          <td><button @click="cal">结账买单~</button></td>
        </tr>
        <tr>
          <td>
            <p>结账单：单价{{totalPrice}}￥ 折后：{{dis}}￥ 省了：{{save}}￥</p>
          </td>
        </tr>
      </table>
    </div>
    <script>
      const app = new Vue({
        el: ".app",
        data: {
          count: 0,
          totalPrice: 0,
          dis: 0,
          save: 0,
        },
        methods: {
          cal() {
            this.totalPrice = this.count * 10;
            this.dis = this.totalPrice * 0.8;
            this.save = this.totalPrice - this.dis;
          },
        },
      });
    </script>
  </body>
</html>
